<?php
    header('Location: http://localhost/finanfacil/index.php');
    $link   = mysqli_connect("localhost","root","","finanfacil");
    $query = "SELECT cd_usuario, nm_usuario FROM usuarios WHERE nm_senha = ? AND nm_usuario = ?";
    $stmt   = mysqli_prepare($link, $query);
    mysqli_stmt_bind_param($stmt, 'ss', $nm_senha, $nm_usuario);
    $nm_senha = $_POST['pwd'];
    $nm_usuario = $_POST['t_login'];
    mysqli_stmt_execute($stmt);
    mysqli_stmt_bind_result($stmt, $cd_usuario, $nm_usuario);
    session_start();
    while (mysqli_stmt_fetch($stmt)){
        $_SESSION['cd_usuario'] =$cd_usuario;
        $_SESSION['nm_usuario'] =$nm_usuario;
    }
?>